package com.tinkerapps.protocols;

import com.tinkerapps.protocols.ssdp.DeviceNotificationSink;
import com.tinkerapps.protocols.ssdp.SSDPControlPoint;
import com.tinkerapps.protocols.ssdp.SSDPDevice;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		SSDPControlPoint control = SSDP.getControlPoint(new DeviceNotificationSink() {
			
			@Override
			public void onDeviceAdded(SSDPDevice device) {
				System.out.println("Added: " + device.getId() + " - " + device.getLocationURL());
			}

			@Override
			public void onDeviceRemoved(SSDPDevice device) {
				System.out.println("Removed: " + device.getId() + " - " + device.getLocationURL());
			}
		});
		
		try {
			control.open();
			control.discover(SSDP.DISCOVER_MEDIA_SERVERS_V1, 3);
			System.out.println("Press <ENTER> to stop...");
			System.in.read();
			control.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
